<template>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column label="申请日期" width="180">
      <template slot-scope="scope">
        
        <span style="margin-left: 10px"
          >{{ timestampToTime(scope.row.apply_date) }}
        </span>
      </template>
    </el-table-column>

    <el-table-column label="申请人姓名" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.name }}</span>
      </template>
    </el-table-column>

    <el-table-column label="性别" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.sex }}</span>
      </template>
    </el-table-column>

    <el-table-column label="证件号" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.icd }}</span>
      </template>
    </el-table-column>

    <el-table-column label="居住地址" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.domicile_address }}</span>
      </template>
    </el-table-column>

    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini" @click="handleEdit1(scope.$index, scope.row)"
          >详情</el-button
        >
      </template>
    </el-table-column>

    <el-table-column label="审核状态">
      <template slot-scope="scope">
        <el-button type="primary"  
          >{{ ifStatu(scope.row.person_info_audit,scope.row.pet_infoaudit) }}</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      tableData: [],
      status:-1,
    };
  },
  methods: {
    handleEdit1(index, row) {
      console.log(this.status);
      
      this.$router.push({
        path: "/police/business_handling/registration_info",
        name: "犬只登记审批详情页面",
        params: {
          icd: row.icd,
          status:this.ifStatu1(row.person_info_audit,row.pet_infoaudit),

        },
      });
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    timestampToTime(timestamp) {
      var date=new Date(timestamp);
      console.log(date);
      var str = date.toString();
      str = str.replace(/ GMT.+$/, ""); // Or str = str.substring(0, 24)
      var d = new Date(str);
      var a = [
        d.getFullYear(),
        d.getMonth() + 1,
        d.getDate(),
        d.getHours(),
        d.getMinutes(),
        d.getSeconds(),
      ];
      for (var i = 0, len = a.length; i < len; i++) {
        if (a[i] < 10) {
          a[i] = "0" + a[i];
        }
      }
      str =
        a[0] + "-" + a[1] + "-" + a[2] + " " + a[3] + ":" + a[4] + ":" + a[5];
      return str;
    },
    ifStatu(data1,data2){
      if(data1==0&&data2==0){
        
        return "未审核";
      }else if(data1=1&&data2==1){
        
        return "已通过";
      }else{
        
        return "未通过";
      }
    },
    ifStatu1(data1,data2){
      if(data1==0&&data2==0){
        
        return 0;
      }else if(data1=1&&data2==1){
        
        return 1;
      }else{
        
        return 2;
      }
    },
  },
  mounted() {
    axios
      .get("http://localhost:3031/selectApply", {
        params: {},
      })
      .then((resp) => {
        this.tableData = resp.data;
      });
  },
  computed: {},
};
</script>
<style scoped>

</style>
